package com.shujichen.controller;

import com.shujichen.entity.CompileTask;
import com.shujichen.service.TaskService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 任务控制器
 */
@Slf4j
@RestController
@RequestMapping("task")
public class TaskController {

    @Autowired
    private TaskService taskService;

    /**
     * 查询任务
     */
    @RequestMapping("/query")
    public R<List<CompileTask>> query() {
        return R.ok(taskService.query());
    }

    /**
     * 添加任务
     */
    @RequestMapping("/add")
    public R add() {
        taskService.add();
        return R.ok();
    }

    /**
     * 清空任务
     */
    @RequestMapping("/clear")
    public R clear() {
        taskService.clear();
        return R.ok();
    }

}
